package com.example.hotelapp.Fragment;

import android.app.Activity;
import android.view.View;
import android.widget.TextView;

import com.example.hotelapp.Activity.LoginActivity;
import com.example.hotelapp.Activity.ModifyInfoActivity;
import com.example.hotelapp.Activity.ModifyPwdActivity;
import com.example.hotelapp.Base.BaseFragment;
import com.example.hotelapp.R;

import butterknife.BindView;
import butterknife.OnClick;

import static com.example.hotelapp.Utils.MyCommonUtils.ConfirmShow;
import static com.example.utils.CommonUtils.IntentToPage;
import static com.example.utils.CommonUtils.SharedInfo;

/**
 * 我的页
 */
public class MyFragment extends BaseFragment {

    @BindView(R.id.name)
    TextView name;
    private Activity activity;

    /**
     * 加载布局
     */
    @Override
    protected int setLayoutId() {
        return R.layout.fragment_me;
    }

    /**
     * 初始化
     */
    @Override
    protected void init() {
        activity = getActivity();
        String phone = SharedInfo(activity,"GetPhone","phone");
        if (phone != null){
            name.setText(phone);
        }
    }

    /**
     * 点击事件
     */
    @OnClick({R.id.userinfo, R.id.xiugaimima, R.id.tuichu})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.userinfo:
                IntentToPage(activity, ModifyInfoActivity.class);
                break;
            case R.id.xiugaimima:
                IntentToPage(activity, ModifyPwdActivity.class);
                break;
            case R.id.tuichu:
                ConfirmShow(activity, activity, LoginActivity.class, "确定退出登录吗？");
                break;
        }
    }
}
